package com.tiepbm.cucphamgiadinh.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.tiepbm.cucphamgiadinh.R;

public class ListChapAdapter extends ArrayAdapter<String>{
	private ArrayList<String> items;
	private Activity context;
	
	public ListChapAdapter(Context context, ArrayList<String> items){
		super(context, R.layout.layout_row_listview,items);
		this.items = items;
		this.context = (Activity)context;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = null;
		if (convertView == null) {
			LayoutInflater inflater = context.getLayoutInflater();
			v = inflater.inflate(R.layout.layout_row_listview, null);

			ViewHolder holder = new ViewHolder();
			holder.lblName = (TextView) v.findViewById(R.id.textView1);
			v.setTag(holder);
		} else {
			v = convertView;
		}
		ViewHolder holder = (ViewHolder) v.getTag();
		holder.lblName.setText(items.get(position));
		return v;
	}
	static class ViewHolder {
		private TextView lblName;
		
	}
}
